package cn.tedu.charging.device.controller;

import cn.tedu.common.pojo.vo.StationInfoVO;
import cn.tedu.common.pojo.param.GunStatusUpdateParam;
import cn.tedu.charging.device.service.DeviceService;
import cn.tedu.common.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "设备模块")
@RequestMapping("device")
@RestController
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    /**
     * 获取场站信息
     * @param gunId
     * @return
     */
    @ApiOperation("获取场站信息")
    @GetMapping("/station/info/{gunId}")
    public JsonResult<StationInfoVO> getStationInfo(@PathVariable("gunId") Integer gunId){
        log.debug("获取场站信息-入参:{}",gunId);
        log.debug("获取场站信息-deviceService:入参:{}",gunId);
        StationInfoVO stationInfoVO = deviceService.getStationInfo(gunId);
        log.debug("获取场站信息-deviceService:入参:{},出参:{}",gunId,stationInfoVO);
        return JsonResult.ok(stationInfoVO, "获取场站信息成功");
    }

    /**
     * 更新枪的状态
     */
    @ApiOperation("更新枪的状态")
    @PostMapping("/station/gun/status/update")
    public JsonResult<Boolean> updateGunStatus(@RequestBody GunStatusUpdateParam updateParam){
        log.debug("更新枪的状态-入参：{}",updateParam);
        Boolean result = deviceService.updateGunStatus(updateParam);
        log.debug("更新枪的状态-deviceService-入参:{}出参:{}",updateParam,result);
        return JsonResult.ok(result,"更新枪的状态成功");
    }
}
